<?php

/**
 * Formulaire permettant de changer son login 
 */
class Myspace_Form_Username extends Zend_Form {

    /**
     * Initialisation du formulaire :
     *  - login 
     */
    public function init() {
        $this->addElementPrefixPath('ZendTremplin_Decorator', 'ZendTremplin/decorator/', 'decorator');

        // Ajout d'un champ texte
        $login = new Zend_Form_Element_Text('login');
        $login->addFilter('StringTrim')
                ->addFilter('htmlEntities')
                ->addValidator('StringLength', false, array(3, 10))
                ->setRequired(true)
                ->setLabel('Login')
                ->setAttrib('maxLength', 10)
                ->setValue(Zend_Auth::getInstance()->getIdentity())
                ->setDecorators(array('Default'));
        $validator = new ZendTremplin_Validate_UserInscription();
        $login->addValidator($validator, true);
        $this->addElement($login);

        // Ajout du bouton d'inscription
        $this->addElement('submit', 'submit', array(
            'ignore' => true,
            'label' => 'Change my user name',
        ));
    }

}

